package com.edu.exam.enums.core;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 实体状态枚举
 */
public enum EntityStatus implements BaseEnum {

    /**
     * 活跃
     */
    ACTIVE("ACTIVE", "活跃"),

    /**
     * 已废弃
     */
    DEPRECATED("DEPRECATED", "已废弃"),

    /**
     * 已禁用
     */
    DISABLED("DISABLED", "已禁用");

    private final String code;
    private final String description;

    EntityStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public String getJsonValue() {
        return code;
    }

    public static EntityStatus fromCode(String code) {
        if (code == null || code.trim().isEmpty()) {
            return ACTIVE;
        }

        for (EntityStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return ACTIVE;
    }
}